package com.raising.modules.code.utils;

import freemarker.cache.TemplateLoader;

import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;

public class TemplateLoaderImpl implements TemplateLoader {

    @Override
    public void closeTemplateSource(Object templateSource) throws IOException
    {

    }
    @Override
    public Object findTemplateSource(String param) throws IOException
    {
//                Clob
        return param;
    }
    @Override
    public long getLastModified(Object templateSource)
    {
        System.out.println("getLastModified");
        return -1l;
    }
    @Override
    public Reader getReader(Object templateSource, String encodeType)
            throws IOException
    {
        System.out.println("getReader");
        Clob c=(Clob)templateSource;
        try
        {
            return c.getCharacterStream();
        }
        catch (SQLException e)
        {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
